<form class="form-horizontal" method = "post" action="<?php echo Yii::app()->createUrl('stubasicinfo/update'); ?>">
<div class="well">
    <h5 class="green">我们会为你的个人信息负责，请你放心填写</h5>
  <div class="form-group">
     <div class="col-sm-2">
	     <label for="" class="control-label">个人照片</label>
		 <?php
		     if($stu->pictureUrl == '')
				 echo ' <img class="img-responsive" style="height:164px;width:216px;" src="'.Yii::app()->baseUrl.'/images/no2.jpg">';
			 else
				 echo ' <img class="img-responsive" style="height:164px;width:216px;" src="'.Yii::app()->baseUrl.$stu->pictureUrl.'">';
		 ?>
		
	</div>
	 <div class="col-sm-2">
		<label for="" class="control-label">姓名</label>
		 <input   type="text" class="form-control validate[required]" name="realName" id="" value="<?php echo $stu->realName; ?>">
         <label for="" class="control-label">学号</label>
		<input   type="text" disabled="disabled" class="form-control validate[required]" name = "stuNumber" value="<?php if($stu->stuNumber !== NULL)
																															echo $stu->stuNumber; 
																											             else
																															echo Yii::app()->user->getName();				
																													?>">
	    <label for="" class="control-label">身份证号</label>
		<input   type="text" class="form-control validate[required]" name = "idNum" value="<?php echo $stu->idNum; ?>">
    </div>
	 <div class="col-sm-2">
		<label for="" class="control-label">个人电话</label>
		<input   type="text" class="form-control validate[required,custom[phone]]" name="phoneNum" value="<?php echo $stu->phoneNum; ?>" placeholder="">
        <label for="" class="control-label">家长电话</label>
		<input    type="text" class="form-control validate[required,custom[phone]]" name="parentNum" value="<?php echo $stu->parentNum; ?>" placeholder="">
       <label for="" class="control-label">家庭地址</label>
		<input type="text" class="form-control validate[required]" name="homePlace"  value="<?php echo $stu->homePlace; ?>" placeholder="">
	</div>
	
    <div class="col-sm-3">
		<label class="control-label">年级</label>
          <div class="controls">
            <select class="form-control validate[required]" name="grade">
			<option value="">&nbsp;&nbsp;&nbsp;&nbsp;</option>
			<?php
			   $currentYear = date('Y');
			   $currentYear = (int)$currentYear - 7;
			   for($i = 7;$i>=0;$i--){
				   $y = $currentYear++;
				   if((int)$stu->grade == $y){
					echo ' <option value="'.$y.'" selected="selected" >'.$y.'</option>';
				   }else
				   echo ' <option value="'.$y.'">'.$y.'</option>';
				   
			   }
			?>
              
            </select>
          </div> 
       <label for="" class="control-label">银行卡号</label>
		<input type="text" class="form-control validate[required,custom[number]]" name="bankNum"  value="<?php echo $stu->bankNum; ?>" placeholder="">
		 <label class="control-label">选择银行</label>
          <div class="controls">
            <select class="form-control validate[required]" name="bankName">
			<option value="">&nbsp;&nbsp;&nbsp;&nbsp;</option>
			<?php
			  $banks = array("中国工商银行","招商银行","中国农业银行","中国建设银行","中国银行","中国民生银行","中国光大银行","中信银行","交通银行","兴业银行","中国农业发展银行","中国邮政储蓄银行","中国人民银行","华夏银行");
			  foreach($banks as $b){
				  if($stu->bankName == $b)
					echo '<option value="'.$b.'" selected = "selected">'.$b.'</option>';
				  else
					echo '<option value="'.$b.'" >'.$b.'</option>';
				}
			?>
              
              
            </select>
          </div>
	</div>
	 <div class="col-sm-3">
		 <label for="" class="control-label">寝室号</label>
		 <input   type="text" class="form-control validate[required]" name="dormNum"  value="<?php echo $stu->dormNum; ?>" placeholder="">
		  <label for="" class="control-label">民族</label>
		 <input   type="text" class="form-control validate[required]" name="nation"  value="<?php echo $stu->nation; ?>" placeholder="">
		<label class="control-label">专业</label>
          <div class="controls">
            <select class="form-control validate[required]" name="major">
			<option value="">&nbsp;&nbsp;&nbsp;&nbsp;</option>
			<?php
			  
			  foreach($major as $m){
				  if($stu->major == $m->name)
				   echo '<option value="'.$m->name.'" selected="selected">'.$m->name.'</option>';
				  else
				  echo '<option value="'.$m->name.'" >'.$m->name.'</option>';
				  
			  }
			?>
              
            </select>
          </div> 
		  
		 
    </div>
 </div>
 <div class="form-group">
     <div class="col-sm-2">
		
	</div>
	 <div class="col-sm-4">
	
		  <label class="control-label">班级</label>
          <div class="controls">
            <select class="form-control validate[required]" name="classRoom">
			<option value="" id="classroom-after">&nbsp;&nbsp;&nbsp;&nbsp;</option>
			<?php
			   if($stu)
				   echo '<option class="classroom-added" value="'.$stu->classRoom.'" selected="selected">'.$stu->classRoom.'</option>'
			?>
              
            </select>
          </div> 
    </div>
	
    <div class="col-sm-3">
		
		 <label class="control-label">定向区县</label>
          <div class="controls">
            <select class="form-control validate[required]" name="directionalDistrict">
			<option value="">&nbsp;&nbsp;&nbsp;&nbsp;</option>
             <?php
			   foreach($dds as $d){
				   if($stu->directionalDistrict == $d->name)
					   echo '<option value="'.$d->name.'" selected="selected">'.$d->name.'</option>';
				   else
				   echo '<option value="'.$d->name.'">'.$d->name.'</option>';
			   }
			 ?>
             
            </select>
          </div>
	</div>
	 <div class="col-sm-3">
		    <label class="control-label">性别</label>
          <div class="controls">
            <select class="form-control validate[required]" name="gender">
              <?php
			     switch($stu->gender){
					 case "男" : echo '<option value="女">女</option><option value="男" selected = "selected">男</option>';break;
					 case "女" : echo '<option value="女" selected="selected">女</option><option value="男" >男</option>';break;
					 default:echo '<option value="女" selected="selected">女</option><option value="男" >男</option>';
				 }
			  ?>
			  
            </select>
          </div>
	</div>
 </div>
 <div class="form-group">
  <div class="col-sm-2">
  </div>
   <div class="col-sm-10">
		  <label for="" class="control-label">备注:</label>
		<textarea class="form-control" name="remark" cols="120" rows="5" > <?php echo $stu->remark; ?></textarea>
	    
	</div>
 </div>
 <div class="form-group">
     <div class="col-sm-5">
	 </div>
	  <div class="col-sm-2">
		<button type="submit" class="btn btn-info">提交</button>
	</div>
 </div>
 </div>
</form>
<hr>
<div class="well">
   <label class="control-label">学习成绩</label>
  <table class="table table-striped table-bordered">
      <thead>
        <tr>
          <th>大一</th>
          <th>大二</th>
          <th>大三</th>
          <th>大四</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <?php
		  echo
		  '<td>'.$stuPer->term_1.'</td>
		  <td>'.$stuPer->term_3.'</td>
		  <td>'.$stuPer->term_5.'</td>
		  <td>'.$stuPer->term_7.'</td>
         
          ';
        ?>
		</tr>
        <tr>
           <?php
		  echo
		  '<td>'.$stuPer->term_2.'</td>
		  <td>'.$stuPer->term_4.'</td>
		  <td>'.$stuPer->term_6.'</td>
		  <td>'.$stuPer->term_8.'</td>
         
          ';
        ?>
        </tr>
      </tbody>
    </table>

</div>
<script type="text/javascript">
  jQuery(function($){
	  var classRoom;
	  <?php
	    $data = array();
		foreach($major as $m){
			$data[$m->name] = array();
			$classes = $m->classrooms;
			foreach($classes as $c){
				$data[$m->name][] = $c->name; 
			}
		}
	   echo 'classRoom = '.json_encode($data);
	  ?>
	  
	  $('[name="major"]').on('change',function(){
		 $('.classroom-added').remove();
		var major = $(this).val();
        for(c in classRoom[major]){
			text = '<option class="classroom-added" value="'+classRoom[major][c]+'">'+classRoom[major][c]+'</option>';
			$('#classroom-after').after(text);
		}		
		 
		  
	  });
	  
  })

</script>